<template>
    <div>
        请输入用户名<input type="text"
            v-model="userName">
        <button @click="login">登录</button>
    </div>
</template>
<script>
import { mapActions } from 'vuex';
export default {
  name: 'login',
  data() {
    return {
      userName: ''
    };
  },
  methods: {
    ...mapActions(['setUser','clearClientContentList']),
    login() {
      this.setUser({ userName: this.userName.replace(/(^\s)|(\s$)/g, '') });
      this.$router.push({ path: '/RoomList', name: 'RoomList' });
      this.clearClientContentList();
    }
  }
};
</script>
